﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Kopytko.BoardGame;
using Chess.Pawns;
using Kopytko.GameBase;

namespace Chess
{
    class ChessLogicWrapper : ChessLogic
    {
        public override Kopytko.BoardGame.Pawns Pawns
        {
            get
            {
                Kopytko.BoardGame.Pawns pawns = new Kopytko.BoardGame.Pawns();



                for (int x = 0; x < 8; x++)
                {
                    for (int y = 0; y < 8; y++)
                    {
                        var fig = PlanszaGry.PobierzFigureZPola(new Kopytko.BoardGame.Pole(x, y));

                        if (fig != null && !(fig is Puste))
                        {
                            var pawn = new ChessPawn(fig);
                            pawns.Add(pawn);
                        }

                    }
                }

                return pawns;
            }
            protected set
            {
                base.Pawns = value;
            }
        }


        public override void Init()
        {
            Player1 = new BoardPlayer(0, PawnColor.Black, PlayerType.Human)
            {
                Name = "Gracz 1",
            };
            Player2 = new BoardPlayer(1, PawnColor.White, PlayerType.Human)
            {
                Name = "Gracz 2",
            };
            

            base.Init();
        }

        public override MoveResult Move(BoardPosition currentPosition, BoardPosition destPosition)
        {
            var result = base.Move(currentPosition, destPosition);
            OnReload();

            return result;
        }
    }
}
